var date = new Date();
var amount = 0;
var checkClickStatus = 0;
var nameGuestGroup = "";
var checkDataPayment = 0;
var checkdata = 0;
var checkDataPaymentAll = 0;
var checkdataAmount = 0;
var amountAll = 0.00;
var checkClickStatus = 0;
var text = "";
function updateFrontPaymentList(repeat){
	//var timeRepeat = 5000;
	var timeRepeat = 60000;
	if(!$("#frontPayment").is(":visible")){
		if(repeat) window.setTimeout(function(){updateFrontPaymentList(repeat);}, timeRepeat);
		return;
	}
	componentLoading($("#frontPayment"));
	simpleserviceWithError("/paymentService",{func:"GetFrontPayment"},function(data,repeat){
		var objArray = JSON.parse(data);
		$("#allAmount").html(toCurrencyString(objArray.Tl,true));
		$("#hordingListDiv").find("tr.hoardingList").remove();
		$("#hordingListDiv").find("tr.lnList").remove();
		for(var i =0;i<objArray.Lst.length;i++){
			var nm = (objArray.Lst[i].gId!=null)? "G" : (objArray.Lst[i].rm + "/" + objArray.Lst[i].nm);
			var type = (objArray.Lst[i].gId!=null)? "pamentPageG":"pamentPageS";
			var rs = (objArray.Lst[i].gId!=null)? objArray.Lst[i].gId:objArray.Lst[i].rs;
			$("#hordingListDiv").find("tr:last").after('<tr class="hoardingList">'
				+ '<td align="center">'
				+ '<p class="output">'
				+ objArray.Lst[i].t
				+ '</p>'
				+ "</td>"
				+ '<td align="left" >'
				+ '<p class="output">'
				+ nm
				+ '</p>'
				+ "</td>"
				+ '<td align="right">'
				+ '<p class="amount"><span class="link" onClick="OpenPaymentForPaymentComponent('+rs+',\''+type+'\')">'
				+ parseFloat(objArray.Lst[i].a).toFixed(2)
				+ '</span></p>'
				+ "</td>"
				+ "</tr>"
				+ '<tr class="lnList"><td align="center" colspan="3" style="padding: 0px; margin: 0px; height: 1px;" ><p class="bottom"></p></td></tr>'
			);
		}
		closeComponentLoading($("#frontPayment"));
		if(repeat) window.setTimeout(function(){updateFrontPaymentList(repeat);}, timeRepeat);
	},function(data,repeat){
		closeComponentLoading($("#frontPayment"));
	},repeat);
}
function AllHoardingList(){
	var headHtml = '<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">' +
	'<title>Room Reservation Check In</title>' +
	'<script src="js/jquery-1.8.3.min.js"></script>'+
	'<link href="https://695.staygrid.com/styles/billmsg.css" rel="stylesheet" type="text/css">' +
	'<style media="print">' +
	'.dont-print-buttom{' +
	'display:none;' +
	'}' +
	'P.pagebreakhere {page-break-before: always}' +
	'</style>'+
	'</head><body>';
	simpleserviceWithError("/paymentService",{func:"getPaymentAll"},function(data){
		var objArray = JSON.parse(data);
		var roomName = "";
		var textAll = "";
		var sumAmount = 0;
		
		for(var i =0;i<objArray.PaymentList.length;i++){
			var date = new Date(objArray.PaymentList[i].paydate);
			var HoursRes = date.getHours();
			var MinuteRes = (date.getMinutes() < 10 ? '0' : '') + date.getMinutes();
			var Time = (HoursRes + ":" + MinuteRes);
			if(objArray.PaymentList[i].roomname==undefined){
				roomName = "G"
			}else{
				roomName = objArray.PaymentList[i].roomname;
			}
				textAll += '<tr class="hoardingList">'
					+ '<td  width="25%" align="center" >'
					+ '<p class="output">'
					+ Time
					+ '</p>'
					+ "</td>"
					+ '<td  width="40%" align="left" >'
					+ '<p class="output">'
					+ roomName
					+ '/'
					+ objArray.PaymentList[i].name
					+ ''
					+ '</p>'
					+ "</td>"
					+ '<td width="35%" align="right" >'
					+ '<p class="amount"><span class="link">'
					+ toCurrencyString(objArray.PaymentList[i].payment)
					+ '</span></p>'
					+ "</td>"
					+ "</tr>";
		}
		myWindow=window.open('','','width=783,height=722');
		
		myWindow.document.write(headHtml+"<table width=\"100%\"><tr><td align=\"center\" colspan=\"3\">"+hoardingList+
				"<hr></td><tr><td align=\"center\">"+hoardingTime+"<hr></td><td>"+hoardingRoomCustomer+"<hr></td><td align=\"right\">"+hoardingAmount+"<hr></td></tr>"+
				"</td></tr>"+textAll+"<tr><td align=\"center\"><hr>"+hoardingAllAmount+"<hr></td><td colspan=\"2\" align=\"right\"><hr>"+toCurrencyString(objArray.PaymentAmount)+"<hr></td></tr></table>"+'</body></html>');
		myWindow.focus();
	});
}